﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using ProjectStorageLib.Project;

public partial class controls_FactorsInapplicability : System.Web.UI.UserControl
{
    #region 

    public string IDProject
    {
        set
        {

            ViewState["ProjectID"] = value == "" ? 0 : Convert.ToDecimal(value);
        }
    }

    public decimal ProjectID
    {
        get
        {
            return ViewState["ProjectID"] == null ? decimal.MinValue : (decimal)ViewState["ProjectID"];
        }
        set
        {
            ViewState["ProjectID"] = value;
        }
    }
    
    #endregion Vars

    protected void Page_Load(object sender, EventArgs e)
    {
        lMess.Visible = false;
        lMess.InnerText = "";

        LoadData();
    }

    private void LoadData()
    {

        ProjectInapplicability inapp = null;

        try
        {
            //Create processor
            inapp = new ProjectInapplicability();

            //load data
            rpInapplicable.DataSource = inapp.GetInapplicabilePractice(ProjectID);
            rpInapplicable.DataBind();

        }
        catch (Exception err)
        {
            lMess.Visible = true;
            lMess.InnerText = err.ToString();
        }
        finally
        {
            if (inapp != null)
                inapp.Dispose();
        }
    }

    #region Button events

    protected void bMore_Click(object sender, EventArgs e)
    {
        try
        {
            //LoadLabels();

            LoadData();

            mpeRoute.Show();
        }
        catch (Exception)
        {

        }
    }

    protected void bClose_Click(object sender, ImageClickEventArgs e)
    {
        mpeRoute.Hide();
    }

    #endregion Button events
}